package com.xian.im.modules.im.core.account;

import com.xian.im.common.enums.UniqueTypeGenerateEnums;
import com.xian.im.common.model.dto.OrganizationDto;
import com.xian.im.modules.im.core.IOrganizationCoreService;
import com.xian.im.modules.security.TokenProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @program: xian-code
 * @description:
 * @author: liru.xian
 * @create: 2021-01-21 20:28
 **/
@Service
public class OrgAccountCoreServiceImpl extends AbsAccountCore {

    @Autowired
    private IOrganizationCoreService organizationService;
    @Autowired
    private TokenProvider tokenProvider;
    /**
     * 校验是否在线
     *
     * @param account
     * @param channel
     * @return
     */
    @Override
    public Boolean checkOnline(String account, String channel) {
        OrganizationDto entity = organizationService.getByUnique(account);
        if (entity != null) {
            return tokenProvider.checkOrgOnline(entity);
        }
        return Boolean.FALSE;
    }

    /**
     * 前缀匹配
     *
     * @return
     */
    @Override
    public UniqueTypeGenerateEnums isMatch() {
        return UniqueTypeGenerateEnums.xim_ORG;
    }
}
